package model;

import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Training-Model
 * 
 * @author Safran Quader
 * @version 0.2
 *
 */

public class Training implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = -1496532303718268568L;
	private int trainingsID;
	private Date anfangsdatum;
	private Date enddatum;
	private int tage;
	
	private ManagementAssistent managementassistent; // 0..* Training <-> 0..1 ManagementAssistent
	private Ort ort; // 0..* Training <-> 0..1 Ort
	private Trainer trainer; // 0..* Training <-> 0..1 Trainer
	private Produkt produkt; // 0..* Training <-> 0..1 Produkt
	private Kunde kunde; // 0..* Training <-> 0..1 Kunde
	
	public Training(){
		this.trainingsID = -1;
		this.anfangsdatum = new Date();
		this.enddatum = new Date();
		this.tage = 0;
		
		this.setManagementassistent(null);
		this.setOrt(null);
		this.setTrainer(null);
		this.setProdukt(null);
		this.setKunde(null);
	}
	
	public Training(int trainingsID, Date anfangsdatum, Date enddatum, int tage, ManagementAssistent managementassistent, Ort ort, Trainer trainer, Produkt produkt, Kunde kunde){
		this.trainingsID = trainingsID;
		this.anfangsdatum = anfangsdatum;
		this.enddatum = enddatum;
		this.tage = tage;
		this.setManagementassistent(managementassistent);
		this.setOrt(ort);
		this.setTrainer(trainer);
		this.setProdukt(produkt);
		this.setKunde(kunde);
	}
	
	public int getTrainingsID() {
		return trainingsID;
	}
	public void setTrainingsID(int trainingsID) {
		this.trainingsID = trainingsID;
	}
	public Date getAnfangsdatum() {
		return anfangsdatum;
	}
	public void setAnfangsdatum(String anfangsdatum) {
		java.util.Date datum = null;
		try {
			datum = java.text.DateFormat.getDateInstance().parse(anfangsdatum);
		} catch (ParseException e) {
			try {
				SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
				datum = formatter.parse(anfangsdatum);
			} catch (ParseException ex) {
				// TODO Auto-generated catch block
				ex.printStackTrace();
			}
		}
		this.anfangsdatum = datum;
	}
	public Date getEnddatum() {
		return enddatum;
	}
	public void setEnddatum(String enddatum) {
		java.util.Date datumende = null;
		try {
			datumende = java.text.DateFormat.getDateInstance().parse(enddatum);
		} catch (ParseException e) {
			try {
				SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
				datumende = formatter.parse(enddatum);
			} catch (ParseException ex) {
				// TODO Auto-generated catch block
				ex.printStackTrace();
			}
		}
		this.enddatum = datumende;
	}
	public int getTage() {
		return tage;
	}
	public void setTage(int tage) {
		this.tage = tage;
	}

	public ManagementAssistent getManagementassistent() {
		return managementassistent;
	}

	public void setManagementassistent(ManagementAssistent managementassistent) {
		this.managementassistent = managementassistent;
	}

	public Ort getOrt() {
		return ort;
	}

	public void setOrt(Ort ort) {
		this.ort = ort;
	}

	public Trainer getTrainer() {
		return trainer;
	}

	public void setTrainer(Trainer trainer) {
		this.trainer = trainer;
	}

	public Produkt getProdukt() {
		return produkt;
	}

	public void setProdukt(Produkt produkt) {
		this.produkt = produkt;
	}

	public Kunde getKunde() {
		return kunde;
	}

	public void setKunde(Kunde kunde) {
		this.kunde = kunde;
	}
}
